"use strict";
cc._RF.push(module, '40edbFlpvND46q7X1eT5HGR', 'bunchInGamePage');
// scripts/Game/Page/bunchInGamePage.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameConfig_1 = require("../../engines/configs/gameConfig");
var gameEngine_1 = require("../../engines/gameEngine");
var userInterface_1 = require("../../engines/services/userContent/userInterface");
var Enum_1 = require("../Enum");
var MainRoot_1 = require("../MainRoot");
var InGamePage_1 = require("./InGamePage");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var bunchInGamePage = /** @class */ (function (_super) {
    __extends(bunchInGamePage, _super);
    function bunchInGamePage() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.lbTime = null;
        _this.hintLb = null;
        _this.level = null;
        return _this;
    }
    bunchInGamePage.prototype.bindLevel = function (level) {
        this.level = level;
        this.refrenshCountDown();
    };
    bunchInGamePage.prototype.refrenshCountDown = function () {
        var time = this.level.countDown;
        this.lbTime.string = time.toString();
    };
    bunchInGamePage.prototype.hideTipsBtn = function () {
        this.tipBtn.active = false;
        this.hintLb.active = true;
    };
    bunchInGamePage.prototype.OnTipsBtn = function () {
        gameEngine_1.default.getManagers().soundMgr.playSound('mainSound/anNiu').then();
        if (gameEngine_1.default.getServices().userSrv.getCoins() > 0) {
            gameEngine_1.default.getServices().userSrv.setCoins(-1, true);
            gameEngine_1.default.emit(Enum_1.GAME_EVENT.ON_BTN_TIPS);
        }
        else {
            gameEngine_1.default.getServices().miniGameSrv.getAppApiInstance().loadAndShowVideoAd(function () {
                gameEngine_1.default.emit(Enum_1.GAME_EVENT.ON_BTN_TIPS);
            }, function () {
            }, null, "串串串看广告获得提示");
        }
    };
    bunchInGamePage.prototype.onBtnInitGame = function () {
        gameEngine_1.default.getManagers().soundMgr.playSound('mainSound/anNiu').then();
        var needPower = this.level.getLevelInfo()["subPower"] || 1;
        if (gameEngine_1.default.getServices().userSrv.getPower() - needPower < 0) {
            MainRoot_1.default.UIModel.showUserPropGet(userInterface_1.REWARD_TYPE.POWER, gameConfig_1.default.ADD_ONCE_POWER);
            return;
        }
        gameEngine_1.default.getServices().userSrv.setPower(-needPower, true, true);
        this.level.countDown = Number(this.level.levelData["time"]);
        this.level.initGame();
    };
    __decorate([
        property({ type: cc.Label, tooltip: "时间文本" })
    ], bunchInGamePage.prototype, "lbTime", void 0);
    __decorate([
        property({ type: cc.Node, tooltip: "提示按钮" })
    ], bunchInGamePage.prototype, "hintLb", void 0);
    bunchInGamePage = __decorate([
        ccclass
    ], bunchInGamePage);
    return bunchInGamePage;
}(InGamePage_1.default));
exports.default = bunchInGamePage;

cc._RF.pop();